flat assembler
Message board for the users of flat assembler.
Index
> Non-x86 architectures > MCS-80/85 |
Author |
|
shoorick 18 Aug 2015, 07:03
Here is the new support for i8080/85 CPUs
I decided to put it separately from the old thread as it uses now fasmg not fasm and much more convenient in use. Bug reports welcome
_________________ UNICODE forever! Last edited by shoorick on 10 Nov 2016, 22:07; edited 5 times in total |
||||||||||||||||||||||||||||||
18 Aug 2015, 07:03 |
|
shoorick 04 Aug 2016, 15:25
an integer square root of dword for i8080:
Code: ;======================================================================= ; BC = SQRT(DEHL) ;----------------------------------------------------------------------- sqrt32: ;----------------------------------------------------------------------- mvi a,30 + 2 push psw ; s+2 lxi b, 0 ; y push d ; xh push h ; xl ;----------------------------------------------------------------------- .loop: pop h pop d pop psw sui 2 ; a=s rm ;----------------------------------------------------------------------- push psw push d push h mov l,c mov h,b dad h mov c,l mov b,h ; BC=y=2*y ;----------------------------------------------------------------------- lxi d,0 dad h inx h ; DEHL=b=2*y+1 ;----------------------------------------------------------------------- inr a .shift: dcr a jz .skip xchg dad h jc .loop xchg dad h jnc .shift inx d jmp .shift .skip: ; DEHL << A=s ;----------------------------------------------------------------------- push d push h lxi h,4 dad sp xchg ; DE --> X lxi h,0 dad sp ; HL --> B ;----------------------------------------------------------------------- ldax d sub m mov m,a inx h inx d ldax d sbb m mov m,a inx h inx d ldax d sbb m mov m,a inx h inx d ldax d sbb m mov m,a ;----------------------------------------------------------------------- pop h pop d jc .loop ;----------------------------------------------------------------------- xthl pop h xchg xthl push d inx b jmp .loop ;======================================================================= _________________ UNICODE forever! |
|||
04 Aug 2016, 15:25 |
|
shoorick 23 Aug 2016, 07:32
a realisation of dividing to 10 via shifting.
the basic implementation was taken there: Code: unsigned divu10(unsigned n) { unsigned q, r; q = (n >> 1) + (n >> 2); q = q + (q >> 4); q = q + (q >> 8); q = q + (q >> 16); q = q >> 3; r = n - q*10; return q + ((r + 6) >> 4); // return q + (r > 9); } ported to: Code: ;======================================================================= ; HL [DE] = HL/10 ;----------------------------------------------------------------------- proc udiv10 ;----------------------------------------------------------------------- ora a mov a,h rar mov b,a mov a,l rar mov c,a ; bc = n >> 1 ora a mov a,b rar mov d,a mov a,c rar add c mov e,a mov c,a mov a,d adc b mov b,a mov d,a ; bc = de = (hl>>1)+(hl>>2) = q xchg ; de = n xra a call shr_hl.s4 ; hl = q >> 4 dad b ; hl = q = q + (q>>4) mov c,h mvi b,0 dad b ; hl = q = q + (q>>8) xra a call shr_hl.s3 ; hl = q = q >> 3 mov b,h mov c,l ; bc = q dad h dad h dad b dad h ; hl = q*10 mov a,e sub l mov e,a ; e = r mvi d,0 adi 6 rar rar rar rar ani 15 ; a = (r+6)>>4 add c mov l,a mov h,b rnc inr h ret ;----------------------------------------------------------------------- .dummy = shr_hl ;----------------------------------------------------------------------- endp ;======================================================================= ; ;======================================================================= ; A MUST BE 0 ! ;----------------------------------------------------------------------- proc shr_hl ;----------------------------------------------------------------------- .s1:dad h ral .s2:dad h ral .s3:dad h ral .s4:dad h ral .s5:dad h ral .s6:dad h ral .s7:dad h ral mov l,h mov h,a ret ;----------------------------------------------------------------------- endp ;======================================================================= |
|||
23 Aug 2016, 07:32 |
|
shoorick 09 Sep 2016, 12:52
a multibyte mathematic is tested - you may check it with attached project. new library and latest fasmg required to compile!
_________________ UNICODE forever! |
||||||||||||||||||||||||||||||
09 Sep 2016, 12:52 |
|
jmg 20 Sep 2016, 21:33
shoorick wrote: Here is the new support for i8080/85 CPUs This is cool. I'm curious about one macro detail you used. I see irp used Code: irp <mnem,opcode>,XCHG?,0EBh,PCHL?,0E9h,XTHL?,0E3h,SPHL?,0F9h,\ RLC?, 007h,RRC?, 00Fh,RAL?, 017h,RAR?, 01Fh,\ DAA?, 027h,CMA?, 02Fh,STC?, 037h,CMC?, 03Fh,\ NOP?, 000h,RET?, 0C9h,RIM?, 020h,SIM?, 030h,\ HLT?, 076h,EI?, 0FBh,DI?, 0F3h macro mnem db opcode end macro end irp That gives quite compact macros, but is it slower/==/faster? than creating a macro-per-opcode ? Seems the irp has to loop to build the macros, but it does save file-lines-read, and this does run once, compared to many more opcodes in user source files. |
|||
20 Sep 2016, 21:33 |
|
revolution 21 Sep 2016, 00:06
jmg wrote: ... but is it slower/==/faster? than creating a macro-per-opcode ? |
|||
21 Sep 2016, 00:06 |
|
jmg 21 Sep 2016, 00:42
revolution wrote: You can test that for yourself with your computer. Let us know the results. OK, yes that is one 'answer'.... Perhaps a better answer, will come from someone who may have done this already, which is what I was asking ? |
|||
21 Sep 2016, 00:42 |
|
shoorick 21 Sep 2016, 02:25
it is slower, sure, maybe, for few µs
A while I do not see any delay with assembling. I can not fit a program more than 32kB into the such model of computer, but even if it were some seconds for assembling, it would not be bothering me Code: C:\spec\fasmg\fasmg.exe DEMO.asm DEMO.rks flat assembler g version 0.97.1471502275 4 passes, 0.3 seconds, 3066 bytes. |
|||
21 Sep 2016, 02:25 |
|
al_Fazline 05 Jan 2023, 08:58
Hello. I have tried to execute the example binary in Radio 86rk emulator (emu80v4), and it seems to just freeze in infinite loop, however the instructions seem to assemble correctly (assembly listing matches debug view disassembly).
Maybe it's meant for a different machine, but the file doesn't have any comments telling which machine it's for. |
|||
05 Jan 2023, 08:58 |
|
shoorick 06 Jan 2023, 20:32
what exactly was the example which you've tried to execute in radio 86rk emulator?
|
|||
06 Jan 2023, 20:32 |
|
al_Fazline 06 Jan 2023, 21:33
shoorik, there is only one in 8085.zip
|
|||
06 Jan 2023, 21:33 |
|
shoorick 07 Jan 2023, 05:10
it is an example to demonstrate pure binary assembling only.
to see anything in radio-86rk emulator you need use calls to rom functions or more complex write characters to the video memory directly. also, file to use with those 8-bit emulators must have header and tail as at the tape, there are start and end addresses to load body and the checksum. rks.inc is to build those things (it produces wrong checksum for rk, as it was created for Specialist and not finished, those models have different bytes order for checksum) try this to see anything in emu80: Code: ;======================================================================= include "8085.inc" include "rks.inc" ;----------------------------------------------------------------------- rk_start ;----------------------------------------------------------------------- lxi h,hello call 0F818h ; output string call 0F803h ; wait for key pressed jmp 0F800h ; warm boot hello: db 10,10,13,"HELLO",0 ;----------------------------------------------------------------------- rk_end ;======================================================================= output binary must have .rk extension in emu80 press I<enter> and select this rk file, it will load it and show checksum error - ignore it then press G<enter> to see the message, then any key to reboot (it's just an example)
_________________ UNICODE forever! |
||||||||||||||||||||||||||||||
07 Jan 2023, 05:10 |
|
al_Fazline 11 Jan 2023, 22:17
Why not to implement correct trailer for RK tape format? You can use bin2tape tool as reference how to do it.
You need to add `00 00 E6 CKHI CKLO` at the end of your file. 00 00 are optional, but I guess it's better to keep them for compatibility. The checksum is written as big-endian 16-bit value. It is calculated by summing all but last byte times 101, then adding last byte of data only to the low byte of sum without carry to high 8 byte. |
|||
11 Jan 2023, 22:17 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.