flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Non-x86 architectures > MCS-80/85

Author
Thread Post new topic Reply to topic
shoorick



Joined: 25 Feb 2005
Posts: 1558
Location: Ukraine
MCS-80/85
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 Wink


Description:
Filesize: 13.69 KB
Viewed: 2301 Time(s)

8080-demo-2016.png


Description: Some examples for real Soviet i8080 home made computers
Download
Filename: 8085STUFF.zip
Filesize: 21.91 KB
Downloaded: 194 Time(s)

Description: Minimal application to place to fasmg examples folder
Download
Filename: 8085.zip
Filesize: 2.26 KB
Downloaded: 192 Time(s)


_________________
UNICODE forever!


Last edited by shoorick on 10 Nov 2016, 22:07; edited 5 times in total
Post 18 Aug 2015, 07:03
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1558
Location: Ukraine
New version uploaded.
[-] "$" issue fixed
[-] conditional return bug fixed
[+] old demo with library converted
(you may use Emu or Emu80 to run it, do not forget to press "G<Enter>" to start)

_________________
UNICODE forever!
Post 03 Feb 2016, 12:53
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1558
Location: Ukraine
an integer square root of dword for i8080:

Code:
;=======================================================================
;   BC = SQRT(DEHL)
;-----------------------------------------------------------------------
sqrt32:
;-----------------------------------------------------------------------
    mvi  a,30 + 2
    push psw  ; s+2
    lxi  b0 ; 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!
Post 04 Aug 2016, 15:25
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1558
Location: Ukraine
a realisation of dividing to 10 via shifting.

the basic implementation was taken there:

Code:
unsigned divu10(unsigned n) {
   unsigned qr;
   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
;=======================================================================

Post 23 Aug 2016, 07:32
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1558
Location: Ukraine
a multibyte mathematic is tested - you may check it with attached project. new library and latest fasmg required to compile!


Description:
Filesize: 22.78 KB
Viewed: 1428 Time(s)

mbyte.png


Description:
Download
Filename: MBYTE.0.0.2.1.zip
Filesize: 3.83 KB
Downloaded: 91 Time(s)

Description:
Download
Filename: lib85.0.6.0.1.zip
Filesize: 18.78 KB
Downloaded: 102 Time(s)


_________________
UNICODE forever!
Post 09 Sep 2016, 12:52
View user's profile Send private message Visit poster's website Reply with quote
jmg



Joined: 18 Sep 2016
Posts: 61
Re: MSC-80/85

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.
Post 20 Sep 2016, 21:33
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14494
Location: WTC Building 7
Re: MSC-80/85

jmg wrote:
... but is it slower/==/faster? than creating a macro-per-opcode ?

You can test that for yourself with your computer. Let us know the results.
Post 21 Sep 2016, 00:06
View user's profile Send private message Visit poster's website Reply with quote
jmg



Joined: 18 Sep 2016
Posts: 61
Re: MSC-80/85

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 ?
Post 21 Sep 2016, 00:42
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1558
Location: Ukraine
it is slower, sure, maybe, for few ┬Ás Wink

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 Wink


Code:

C:\spec\fasmg\fasmg.exe DEMO.asm DEMO.rks

flat assembler g  version 0.97.1471502275
4 passes0.3 seconds3066 bytes.

Post 21 Sep 2016, 02:25
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.